package br.ufrgs.meetapp.enums;

import br.ufrgs.meetapp.activities.R;



public enum WebServiceResult {
	
	UNKNOWN_ERROR(99, R.string.webservice_unknown_error), 
	OK(100, R.string.webservice_login_ok), 
	LOGIN_INPUT_ERROR(110, R.string.webservice_login_input_error), 
	ANOTHER_USER_DEVICE_ERROR(111, R.string.webservice_another_user_device_error), 
	NOT_REGISTERED_DEVICE(112, R.string.webservice_unregistered_device),
	COMPANY_INPUT_ERROR(113, R.string.webservice_company_input_error), 
	COMPANY_ALREADY_EXIST(114, R.string.webservice_company_already_exist), 
	REGISTER_FAIL(115, R.string.webservice_register_fail), 
	USER_ALREADY_EXISTS(116, R.string.webservice_user_already_exist), 
	EMAIL_ALREADY_EXISTS(117, R.string.webservice_email_already_exist), 
	USER_REGISTER_FAIL(118, R.string.webservice_user_register_fail),
	NEW_PASSWORD_REQUEST_FAIL(119, R.string.webservice_new_password_request_fail),
	EMAIL_DOES_NOT_EXIST(120, R.string.webservice_email_does_not_exist),
	INVALID_CREDENTIALS(121, R.string.webservice_invalid_credentials),
	CHANGE_PASSWORD_REQUEST(122, R.string.webservice_change_password_request),
	USER_IS_NOT_REGISTERED(123, R.string.webservice_user_is_not_registered),
	UPDATE_PASSWORD_FAIL(124, R.string.webservice_update_password_fail);

	//TODO CREATE STRINGS FOR ERRORS 113 ~ 118
	

	private int resultId;
	private int resultTextReference;

	private WebServiceResult(int _resultId, int _resultTextReference) {
		resultId = _resultId;
		resultTextReference = _resultTextReference;
	}
	
	/***
	 * Returns the ResultType enum by ID
	 * @param _result_id 
	 * @return
	 */
	public static WebServiceResult getType(int _result_id) {
		switch (_result_id) {
			case 99: return WebServiceResult.UNKNOWN_ERROR;
			case 100: return WebServiceResult.OK;
			case 110: return WebServiceResult.LOGIN_INPUT_ERROR;
			case 111: return WebServiceResult.ANOTHER_USER_DEVICE_ERROR;
			case 112: return WebServiceResult.NOT_REGISTERED_DEVICE;
			case 113: return WebServiceResult.COMPANY_INPUT_ERROR;
			case 114: return WebServiceResult.COMPANY_ALREADY_EXIST;
			case 115: return WebServiceResult.REGISTER_FAIL;
			case 116: return WebServiceResult.USER_ALREADY_EXISTS;
			case 117: return WebServiceResult.EMAIL_ALREADY_EXISTS;
			case 118: return WebServiceResult.USER_REGISTER_FAIL;
			case 119: return WebServiceResult.NEW_PASSWORD_REQUEST_FAIL;
			case 120: return WebServiceResult.EMAIL_DOES_NOT_EXIST;
			case 121: return WebServiceResult.INVALID_CREDENTIALS;
			case 122: return WebServiceResult.CHANGE_PASSWORD_REQUEST;
			case 123: return WebServiceResult.USER_IS_NOT_REGISTERED;
			case 124: return WebServiceResult.UPDATE_PASSWORD_FAIL;
			
			default: return WebServiceResult.UNKNOWN_ERROR;
		}
	}
	
	/***
	 * Returns the result type id
	 * @return
	 */
	public int getResultId() {
		return resultId;
	}
	
	/***
	 * Returns the result text reference to access the strings file
	 * @return
	 */
	public int getResultTextReference() {
		return resultTextReference;
	}
}
